import request from '@/utils/request'

// 素材列表
export function fetchMateriaList(params) {
  return request({
    url: '/operation/opMediaFile/queryList',
    method: 'get',
    params: {
      'directoryId': params.directoryId,
      'fileName': params.fileName,
      'fileType': params.fileType,
      'startDate': params.startDate,
      'endDate': params.endDate,
      'status': params.status,
      'pageIndex': params.pageIndex,
      'pageSize': params.pageSize
    },
    port: { ENV_PORT: 8004 },
    ajaxType2: 'reqGet'

  })
}

// 素材详情
export function materiaDetail(id) {
  return request({
    url: '/operation/opMediaFile/detail',
    method: 'get',
    params: { 'id': id },
    port: { ENV_PORT: 8004 },
    ajaxType2: 'reqGet'
  })
}

// 素材上传
export function materiaAdd(data) {
  return request({
    url: '/operation/opMediaFile/add',
    method: 'post',
    hearder: { orgId: data.orgId },
    data,
    port: { ENV_PORT: 8004 },
    ajaxType: 'formdata',
    ajaxType2: 'reqPost'

  })
}

// 素材预览
export function materiaView(id) {
  return request({
    url: `/operation/opMediaFile/view/${id}`,
    method: 'get',
    port: { ENV_PORT: 8004 },
    responseType: 'arraybuffer',
    ajaxType2: 'reqGet'

  })
}

// 素材修改
export function materiaUpdate(data) {
  return request({
    url: '/operation/opMediaFile/update',
    method: 'put',
    data,
    port: { ENV_PORT: 8004 },
    ajaxType2: 'reqPut'

  })
}

// 删除素材
export function materiaDelete(id) {
  return request({
    url: '/operation/opMediaFile/delete',
    method: 'delete',
    params: { id },
    port: { ENV_PORT: 8004 },
    ajaxType2: 'reqDelete'

  })
}

// 审核素材
export function materiaApprove(data) {
  return request({
    url: '/operation/opMediaFile/approve',
    method: 'put',
    data,
    port: { ENV_PORT: 8004 },
    ajaxType2: 'reqPut'

  })
}
